From ae8f38daae210c1eae804a1094a0c7b1e45993eb Mon Sep 17 00:00:00 2001 From: robertl Date: Wed, 30 Jul 2003 04:54:25 +0000 Subject: [PATCH] Robustify on missing input comments. --- gpsutil.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gpsutil.c b/gpsutil.c index ed5743e5a..c7f349d75 100644 --- a/gpsutil.c +++ b/gpsutil.c @@ -47,6 +47,7 @@ wr_deinit(void) static void data_read(void) { + char ibuf[100]; char name[9], desc[30]; double lat,lon; char latdir, londir; @@ -56,9 +57,14 @@ data_read(void) char icon[3] = {0}; waypoint *wpt_tmp; - while( fscanf(file_in, "%s %le%c %le%c %ld%c %30[^,] %c", + for(;fgets(ibuf, sizeof(ibuf), file_in);) { + sscanf(ibuf, "%s %le%c %le%c %ld%c %30[^,] %c", name, &lat, &latdir, &lon, &londir, - &alt, &alttype, desc, icon) > 0) { + &alt, &alttype, desc, icon); + desc[0] = '\0'; + sscanf(&ibuf[39], "%30c", desc); + sscanf(&ibuf[68], "%2s", icon); + fprintf(stderr, "Icon >%s< Desc >%s<\n", icon, desc); rtrim(desc); wpt_tmp = xcalloc(sizeof(*wpt_tmp),1); wpt_tmp->position.altitude.altitude_meters = alt; -- 2.30.2